import Vue from 'vue'
import Vuex from 'vuex'
import $http from '../utils/http.js'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
		isOpen:false,
		ifLogin:false,
		dictArrs:{}
    },
    mutations: {
		//存字典表数据
		SAVEDICTARRS(state,objs){
			for(let i in objs){
				Vue.set(state.dictArrs,i,objs[i]);
			}
		},
		//判断用户是否登录
        USER_IF_LOGIN(state,bol){
			state.ifLogin = bol;
		},
		OPEN_MID_BTN(state,bol){
			state.isOpen = bol;
		}
    },
	actions:{
	    //字典表 多个组合获取
	    getDictlists({commit},params){
	      $http('/api/unAuth/dict/queryByTypes/'+params,'get',{}).then(res=>{
	        if(res && res.data.code == 0){
	          var lists =res.data.data;
	          commit('SAVEDICTARRS',lists);
	        }
	      });
	    },
	  }
})

export default store
